At this point we can think about writing some functions which will drive the LCD. (code in right pane)
What I have created is a whole bunch of empty functions, each of which will do one of the tasks above. Note that some of them accept parameters which tell them what to do. All of them return a value. The value they return will be used to indicate whether they worked or not. This is very important. You don't have to look at a value a function returns, you can simply call it to do a job for you, but in the case of an LCD we can probably think of ways in which things can go wrong and we must have a way of telling someone this.
For example, you may try to put the cursor onto a line which doesn't exist, or you may try to turn an LCD on which is broken. In either case the function you call should return a value which indicates that an error has been detected (and perhaps what the error is).
This is an example of defensive programming. What this boils down to is "If it goes wrong it is the other person's fault". If someone tries to sue me because my LCD driver didn't work properly when the panel was broken, I can reply that my driver does actually detect this and signals an error value. If the person using my LCD software is ignoring the reply this is their fault and not mine. Case closed.
I am using the convention that 1 means "worked ok" and any other value is an error code. At the moment my functions all return 1, to indicate success.
/* lcd display driver code */ char lcd_start ( void ) { return 1 ; } char lcd_clear ( void ) { return 1 ; } char lcd_print_ch ( char ch ) { return 1 ; } char lcd_print ( const char * message ) { return 1 ; } char lcd_cursor ( char x, char y ) { return 1 ; }